#九九乘法表
#右上三角形
print('=' * 15, '三角形', '=' * 15)
for i in range(1,10):
    for j in range(1,i+1):
        print('{0}*{1}={2}'.format(j,i,i*j),end='  ')
    print('')


i = 1
while i<10:
    j = 1
    while j<=i:
        print('{0}*{1}={2}'.format(i,j,i*j),end='  ')
        j+=1
    print('')
    i+=1

#右下三角形
print('=' * 15, '三角形', '=' * 15)
for i in range(1,10):
    for j in range(1,10-i):
         print(end='       ')#控制前面的空白
    for t in  range(i,0,-1):
        print("%d*%d=%2d" % (t, i, t * i), end=' ')
    print("")

i=1
while i<10:
    t=1
    while t<10-i:
        print(end='       ')
        t+=1
    j = i
    while j>0:
        print("%d*%d=%2d"%(j,i,j*i),end=' ')
        j-=1
    print("")
    i+=1

#左上三角形
print('=' * 15, '三角形', '=' * 15)
for i in range(9,0,-1): #参数：计数从9开始，0结束，步长-1
    for j in range(1,i+1):
         print("%d*%d=%d"%(j,i,j*i),end=' ')
    print("")

i = 9
while i>=1:
    j = 1
    while j<=i:
        print("%d*%d=%d"%(j,i,j*i),end=' ')
        j+=1
    print('')
    i-=1

#左下三角形
print('=' * 15, '三角形', '=' * 15)
for i in range(9,0,-1):
    for k in range(i, 9):
        print(end='       ')
    for j in range(i,0,-1):
        print("%d*%d=%2d"%(i,j,j*i),end=' ')
    print("")

i = 9
while i>0:
    k = i
    while k<9:
        print(end='       ')
        k+=1
    j = i
    while j>0:
        print("%d*%d=%2d" % (i, j, j * i), end=' ')
        j-=1
    print("")
    i-=1
